Crate bevy_framepace

source ·
Expand description

This is a bevy plugin that adds framepacing and framelimiting to improve input latency and power use.

How it works

This works by sleeping the app immediately before the event loop starts. In doing so, this minimizes the time from when user input is captured (start of event loop), to when the rendered frame using this input data is presented (RenderStage::Render). Because the event loop is, well, a loop, it is equally accurate to think of this as sleeping at the beginning of the frame, before input is captured. Graphically, it looks like this:

 /-- latency --\             /-- latency --\
 input -> render -> sleep -> input -> render -> sleep
 \----- event loop -----/    \----- event loop -----/

One of the interesting benefits of this is that you can keep latency low even if the framerate is limited to a low value. Assuming you are able to reach the target frametime, there should be no difference in motion-to-photon latency when limited to 10fps or 120fps.

      same                        same
 /-- latency --\             /-- latency --\
 input -> render -> sleep    input -> render -> sleeeeeeeeeeeeeeeeeeeeeeeep
 \----- event loop -----/    \---------------- event loop ----------------/
          60 fps                           limited to 10 fps

Modules

Adds diagnostic logging and a cursor for debugging.

Structs

Holds frame time measurements for framepacing diagnostics
Tracks the instant of the end of the previous frame.
Adds framepacing and framelimiting functionality to your [App].
Framepacing plugin configuration.
Current frametime limit based on settings and monitor refresh rate.

Enums

Configures the framelimiting technique for the app.

Functions

Accurately sleeps until it’s time to start the next frame.